package com.baturu.vin.ford.dal.dao;

import com.baturu.vin.ford.dal.entity.FordV2PartsInfoEntity;
import com.baturu.vin.ford.dto.FordV2BtrRuleDTO;
import com.baturu.vin.ford.dto.FordV2ImageInfoDTO;
import com.baturu.vin.ford.dto.FordV2ImagePointDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

/**
 * @Author: chenjiahao
 * @Time: 2019/1/24
 */
public interface FordV2PartsInfoDAO {
    @Select({"<script>SELECT pnc,imageCode, dealReplacePartsCode,carTypeId, dealPartsCode, subGroup, subGroupIdx, subGroupCondition1, subGroupCondition2, textCondition2, dealTextCondition3, condition1, condition2, condition3, dealBegin, dealEnd, count" ,
            "FROM ford_epc_parts_detail",
            "WHERE dealPartsCode in ",
            "<foreach item = 'item' collection= 'partsCodes' open='(' separator=',' close = ')'>",
            "#{item}",
            "</foreach>",
            "AND carTypeId = #{carTypeId}",
            "</script>"
    })
    List<FordV2PartsInfoEntity> queryPartsInfoByPartsCodeAndSubGroup(@Param("partsCodes") Collection<String> partsCodes, @Param("carTypeId") String carTypeId);

    @Select({"<script>SELECT pnc,imageCode,dealReplacePartsCode,carTypeId, dealPartsCode, subGroup, subGroupIdx, subGroupCondition1, subGroupCondition2, dealTextCondition1, dealTextCondition2, dealTextCondition3, condition1, condition2, condition3, dealBegin, dealEnd, count" ,
            "FROM ford_epc_parts_detail",
            "WHERE dealPartsCode in ",
            "<foreach item = 'item' collection= 'partsCodes' open='(' separator=',' close = ')'>",
            "#{item}",
            "</foreach>",
            "</script>"
    })
    List<FordV2PartsInfoEntity> queryPartsInfoByPartsCode(@Param("partsCodes") Collection<String> partsCodes);

    @Select({"<script>SELECT carTypeId,subGroup,x1 topLeftX ,y1 topLeftY,x2 bottomRightX,y2 bottomRightY,pnc",
            "FROM ford_epc_image_point",
            "WHERE pnc in ",
            "<foreach item='item' collection = 'parts' open='(' separator=',' close = ')'>",
            "#{item.pnc}",
            "</foreach>",
            "AND carTypeId in ",
            "<foreach item='item' collection = 'parts' open='(' separator=',' close = ')'>",
            "#{item.carTypeId}",
            "</foreach>",
            "AND subGroup in ",
            "<foreach item='item' collection = 'parts' open='(' separator=',' close = ')'>",
            "#{item.subGroup}",
            "</foreach>",
            "</script>",
    })
    List<FordV2ImagePointDTO> queryImagePointDTO(@Param("parts") Collection<FordV2PartsInfoEntity> parts);

    @Select({"<script>SELECT subGroup,imageName,pnc,imageCode,url,carTypeId",
            "FROM ford_epc_self_image_info",
            "WHERE imageCode in ",
            "<foreach item='item' collection = 'parts' open='(' separator=',' close = ')'>",
            "#{item.imageCode}",
            "</foreach>",
            "AND carTypeId in ",
            "<foreach item='item' collection = 'parts' open='(' separator=',' close = ')'>",
            "#{item.carTypeId}",
            "</foreach>",
            "AND subGroup in ",
            "<foreach item='item' collection = 'parts' open='(' separator=',' close = ')'>",
            "#{item.subGroup}",
            "</foreach>",
            "</script>",
    })
    List<FordV2ImageInfoDTO> queryImageInfoDTO(@Param("parts") Collection<FordV2PartsInfoEntity> parts);

    @Select("SELECT btr_parts_name,btr_rule FROM ford_epc_self_rules")
    List<FordV2BtrRuleDTO> queryBtrRule();
}
